From e0ca7b883a27919b968dc2c9d2fe2d0096342071 Mon Sep 17 00:00:00 2001 From: Norbert Manthey Date: Fri, 26 Feb 2021 15:41:41 +0100 Subject: [PATCH] xenstore: handle do_mkdir and do_rm failure In the out of memory case, we might return a NULL pointer when canonicalizing node names. This NULL pointer is not checked when creating a directory, or when removing a node. This change handles the NULL pointer for these two cases. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Signed-off-by: Norbert Manthey Reviewed-by: Thomas Friebel Reviewed-by: Julien Grall Reviewed-by: Juergen Gross Release-Acked-by: Ian Jackson --- tools/xenstore/xenstored_core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 3803aef081..8febd09f55 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -1160,6 +1160,8 @@ static int do_mkdir(struct connection *conn, struct buffered_data *in) /* No permissions? */ if (errno != ENOENT) return errno; + if (!name) + return ENOMEM; node = create_node(conn, in, name, NULL, 0); if (!node) return errno; @@ -1274,6 +1276,8 @@ static int do_rm(struct connection *conn, struct buffered_data *in) if (!node) { /* Didn't exist already? Fine, if parent exists. */ if (errno == ENOENT) { + if (!name) + return ENOMEM; parentname = get_parent(in, name); if (!parentname) return errno; -- 2.30.2